<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我赞过的</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<div id="header" style="height: 0.9rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 99">
    <header class="header header-shadow">
        <div class="header-left">
            <div tapmode onclick="comeBack();" class="nav-left"><img class="icon-back" src="../../icon/icon-back.png"/>
            </div>
        </div>
        <h2>我的屏蔽</h2>
    </header>
</div>

<div class="mescroll" id="mescroll" style="padding-top: 1.5rem;">
    <section class="html_section pr30 pl30 ">
        <ul class="userType_list3" style="justify-content: center;">
            <li tapmode class="on shield_li" data-id="1">新闻</li>
            <li tapmode class="shield_li" data-id="2">帖子</li>
            <li tapmode class="shield_li" data-id="3">活动</li>
            <li tapmode data-id="4">用户</li>
        </ul>
        <div class="page_box on shield_li" data-page="1" data-ifpage='true' data-ready='false'>
            <div class="index-news">
                <ul>

                </ul>
            </div>
            <div class="nodata"></div>
        </div>
        <div class="page_box shield_li" data-page="1" data-ifpage='true' data-ready='false'>
            <div class="index-news user-dynamic">
                <ul>

                </ul>
            </div>
            <div class="nodata"></div>
        </div>
        <div class="page_box shield_li" data-page="1" data-ifpage='true' data-ready='false'>
            <div class="activity-list">
                <ul id="actContent">

                </ul>
            </div>
            <div class="nodata"></div>
        </div>
        <div class="page_box" data-page="1" data-ifpage='true' data-ready='false'>
            <div class="person-comment">
                <ul class="pt20">

                </ul>
            </div>
            <div class="nodata"></div>
        </div>
    </section>
</div>

<style type="text/css">
    .follow{display: none!important;}
</style>
</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/mescroll.min.css"/>
<script type="text/javascript" src="../../script/mescroll.min.js"></script>
<script type="text/javascript">
    var type = 1;
    apiready = function () {
        setFixStatusBar(); //设置状态栏
        pop.loading()
        keybackListener()

        api.addEventListener({
            name: 'shield'
        }, function (ret, err) {
            ready();
        });

        var systemType = api.systemType;
        if(systemType == 'android'){
            $('.shield_li').remove();
            $(".userType_list3 li").addClass('on');
            $(".page_box").addClass('on');
            type = 4;
        }else {
            getversion(function(res){
                var sysType = api.systemType;
                if(sysType == 'ios'){
                    if (isDefine(res.data.ios_number)){
                        if(ios_code > res.data.ios_number){

                        }else {
                            $('.shield_li').remove();
                            $(".userType_list3 li").addClass('on');
                            $(".page_box").addClass('on');
                            type = 4;
                        }
                    }
                }
            })
        }

        var isOne = true;
        api.addEventListener({
            name: 'viewappear'
        }, function (ret, err) {
            if (isOne) {
                isOne = false;
                ready();
            }
        });
    }


    //创建MeScroll对象
    var mescroll = new MeScroll("mescroll", {
        down: {
            auto: false, //是否在初始化完毕之后自动执行下拉回调callback; 默认true
            callback: downCallback //下拉刷新的回调
        },
        up: {
            auto: false, //是否在初始化时以上拉加载的方式自动加载第一页数据; 默认false
            isBounce: false, //此处禁止ios回弹,解析(务必认真阅读,特别是最后一点): http://www.mescroll.com/qa.html#q10
            callback: upCallback, //上拉回调,此处可简写; 相当于 callback: function (page) { upCallback(page); }
            /*toTop:{ //配置回到顶部按钮
                src : "../res/img/mescroll-totop.png", //默认滚动到1000px显示,可配置offset修改
                //offset : 1000
            }*/
        }
    });
    /*下拉刷新的回调 */
    function downCallback() {
        $(".page_box.on").data('page', 1);
        $(".page_box.on").data('ifpage', true);
        ready();

        //mescroll.endErr();
    }
    /*上拉加载的回调 */
    function upCallback() {
        var ifpage = $(".page.on").data("ifpage");
        if (ifpage == true) {
            var page = Number($(".page.on").data("page"));
            $(".page.on").data("page", page++);
            ready();
        }else {
            mescroll.endErr();
        }
    }

    function ready() {
        page = $(".page_box.on").data("page");
        getAjax(Interface.get_shield, {token: $api.getStorage('token'), page: page, type: type}, function (res) {
            $(".page_box.on").data('ready', true);
            pop.close();
            var list = res.data.list;
            var html = '';
            $.each(list, function (i, item) {
                if (type == 1) {
                    var toUp = '';
                    var hotHtml = '';
                    if (isDefine(item)) {
                        if (item.recommend == 1) {
                            toUp = '<span class="bt-pd toUp">置顶</span>';
                        }
                        if (isDefine(item.news_label_name)) {
                            if (item.news_label_name.length >= 2) {
                                hotHtml = '<div class="detail-bottom">' +
                                    '              <div class="bottom-tips">' + toUp +
                                    '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + item.news_label_name[0].id + '})\'>#' + item.news_label_name[0].title + '#</span>' +
                                    '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + item.news_label_name[1].id + '})\'>#' + item.news_label_name[1].title + '#</span>' +
                                    '                  <span class="bt-pd time">' + item.date + '</span>' +
                                    '              </div>' +
                                    '              <div class="cancel-shield" tapmode onclick=\'cancelShield('+item.id+',1,this)\'>移出屏蔽</div>' +
                                    '          </div>';
                            } else if (item.news_label_name.length == 1) {
                                hotHtml = '<div class="detail-bottom">' +
                                    '              <div class="bottom-tips">' + toUp +
                                    '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + item.news_label_name[0].id + '})\'>#' + item.news_label_name[0].title + '#</span>' +
                                    '                  <span class="bt-pd time">' + item.date + '</span>' +
                                    '              </div>' +
                                    '              <div class="cancel-shield" tapmode onclick=\'cancelShield('+item.id+',1,this)\'>移出屏蔽</div>' +
                                    '          </div>';
                            }

                        } else {
                            hotHtml = '<div class="detail-bottom">' +
                                '              <div class="bottom-tips">' + toUp +
                                '                  <span class="bt-pd time">' + item.date + '</span>' +
                                '              </div>' +
                                '              <div class="cancel-shield" tapmode onclick=\'cancelShield('+item.id+',1,this)\'>移出屏蔽</div>' +
                                '          </div>';
                        }
                    }

                    var param = {"news_id": item.id}

                    //标题，文字，图片
                    var titleHtml = '';
                    if (isDefine(item.void_ids)) {
                        //视频新闻
                        titleHtml = '<div class="video-detail">' +
                            '             <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' +
                            '             <div class="video-box bg-cover" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\' style="background-image: url(' + ajaxUrl + item.void_icon_path + ')";>' +
                            '                 <p class="single-ellipsis"></p>' +
                            '                 <span class="icon-play"></span>' +
                            '                 <span class="time"></span>' +
                            '              </div>' + hotHtml +
                            '         </div>';

                    } else {
                        //三张图片新闻
                        if (isDefine(item.icon_path)) {
                            if (item.icon_path.length >= 3) {
                                titleHtml = '<div class="video-detail">' +
                                    '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' +
                                    '            <div class="detail-img-list" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[0] + ');"></div>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[1] + ');"></div>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[2] + ');"></div>' +
                                    '            </div>' + hotHtml +
                                    '        </div>'
                            } else if (item.icon_path.length == 2) {
                                //两张图片新闻
                                titleHtml = '<div class="video-detail">' +
                                    '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' +
                                    '            <div class="detail-img-list two-img" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[0] + ');"></div>' +
                                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[1] + ');"></div>' +
                                    '            </div>' + hotHtml +
                                    '        </div>'
                            } else if (item.icon_path.length == 1) {

                                if (item.recommend == 1) {
                                    toUp = '<span class="bt-pd toUp">置顶</span>';
                                }
                                if (isDefine(item.news_label_name)) {
                                    if (item.news_label_name.length >= 1) {
                                        hotHtml = '<div class="detail-bottom">' +
                                            '              <div class="bottom-tips">' + toUp +
                                            '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + item.news_label_name[0].id + '})\'>#' + item.news_label_name[0].title + '#</span>' +
                                            '                  <span class="bt-pd time">' + item.date + '</span>' +
                                            '              </div>' +
                                            '              <div class="cancel-shield" tapmode onclick=\'cancelShield('+item.id+',1,this)\'>移出屏蔽</div>' +
                                            '          </div>';
                                    }

                                }
                                //单张图片新闻
                                titleHtml = '<div class="single-news">' +
                                    '             <div class="detail-img-list" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' +
                                    '                 <div class="img bg-cover" style="background-image: url(' + ajaxUrl + item.icon_path[0] + ');"></div>' +
                                    '             </div>' +
                                    '             <div class="video-detail">' +
                                    '                 <h6 class="news-title multiline-ellipsis_3" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' + hotHtml +
                                   /* '                 <p class="detail-info multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + item.brief + '</p>' + hotHtml +*/
                                    '             </div>' +
                                    '         </div>';
                            }
                        }else {
                            //无图
                            titleHtml = '<div class="video-detail">' +
                                '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + item.title + '</h6>' +
                                '            </div>' + hotHtml +
                                '        </div>'

                        }


                    }

                    html += '<li>' + titleHtml + '</li>'
                } else if (type == 2) {
                    html += tiesList(item,2);
                } else if (type == 3) {
                    html += GetLikeList(item);
                }else if(type == 4){
                    html += shieldUser(item);
                }
            })
            pop.close();
            if (page == 1){
                // console.log(html)
                $(".page_box.on ul").html(html);
            } else {
                $(".page_box.on ul").append(html);
            }
            if (list.length < res.data.sumpage) {
                $(".page_box.on").data('ifpage', false);
                $(".page_box.on .nodata").show();
            } else {
                $(".page_box.on .nodata").hide();
            }
            if (list.length == 0) {
                if (page == 1) {
                    $(".page_box.on .nodata").hide();
                    $(".page_box.on ul").html(noData);
                }
            }
            mescroll.endErr()
        }, function (res, err) {
            mescroll.endErr()
        })
    }

    $(".userType_list3 li").click(function () {
        $(".userType_list3 li").removeClass("on");
        $(this).addClass("on");
        $(".page_box").removeClass("on");
        $(".page_box").eq($(this).index()).addClass("on");
        type = $(this).data("id");
        var ifr = $(".page_box.on").data('ready');
        if (ifr == false) {
            ready();
        }
    })

    //用户
    function shieldUser(item) {
        var titleHtml = '';

        var badge_path = "";
        $.each(item.badge_path, function (k, ktem) {
            if (ktem) {
                badge_path += '<img class="icon-hz ml10" src="' + getImg(ktem) + '" />'
            }
        })
        var result = {"member_id": item.id}

        titleHtml += '<li style="display: flex;justify-content: space-between;align-items: center;">';
            titleHtml += '<div class="like_content" onclick=\'commonUrl("../activity/person_index",' + jsonChange(result) + ')\'>';
                titleHtml += '<div class="member_head bg-cover"  style="background-image: url(' + getImg(item.icon_path) + ');" ></div>';
                titleHtml += '<div class="like_details">';
                    titleHtml += '<div>' + item.name + '</div>'
                if(isDefine(item.autograph) && item.autograph != "0"){
                    titleHtml += '<div class="c-999 f24 single-ellipsis">' + item.autograph + '</div>';
                }else {
                    titleHtml += '<div class="c-999 f24 single-ellipsis">这个人比较懒，没有个性签名</div>';
                }
                titleHtml += '</div>';
            titleHtml += '</div>';
            titleHtml += '<div class="like_shield" tapmode onclick=\'cancelShield('+item.id+',4,this,event)\'>移出屏蔽</div>';
        titleHtml += '</li>';

        return titleHtml;
    }

    //评论
    function GetLikeList(item) {
        var listHtml = '';
        var listData = item;

        var userData = listData.member;
        var userInfo = '';
        var follow = '';//是否关注
        var badgeList = '';//徽章列表
        var toUp = '';//顶置

        var titleHtml = '';
        var hotHtml = '';//标签，热度

        //顶置，标签，热度
        if (listData.recommend == 1) {
            toUp = '<span class="bt-pd toUp">置顶</span>';
        }
        var tips = '';//标签
        if (isDefine(listData.cut_list)) {
            for (var z = 0; z < listData.cut_list.length; z++) {
                tips += '<span class="bt-pd tips">#' + listData.cut_list[z] + '#</span>'
            }
        }
        /*hotHtml = '<div class="detail-bottom">' +
            '              <div class="bottom-tips">' + toUp + tips + '</div>' +
            '              <div class="bottom-hot">' + listData.hot_number + '</div>' +
            '          </div>';*/
        hotHtml = '<div class="detail-bottom">' +
            '              <div class="bottom-tips">' + toUp + tips + '</div>' +
            '              <div class="cancel-shield" tapmode onclick=\'cancelShield('+listData.id+',3,this)\'>移出屏蔽</div>' +
            '          </div>';

        if (isDefine(userData.badge_path)) {
            for (var k = 0; k < userData.badge_path.length; k++) {
                if (k <= 5) {
                    badgeList += '<dd class="icon"><img src="' + ajaxUrl + userData.badge_path[k] + '" alt=""></dd>'
                }
            }
        }
        var user = {'member_id': userData.id};
        userInfo = '<div class="common-user-detail">' +
            '           <div class="user-info" tapmode onclick=\'commonUrl("../activity/person_index",' + jsonChange(user) + ')\'>' +
            '               <div class="user-icon bg-cover" style="background-image: url(' + ajaxUrl + userData.icon_path + ');"></div>' +
            '               <div class="info">' +
            '                    <div class="name">' +
            '                        <h6>' + userData.name + '</h6>' +
            '                        <dl class="badge-list" tapmode onclick="toBadgePage(event)">' + badgeList + '</dl>' +
            '                    </div>' +
            '                    <span class="time">' + listData.date + '</span>' +
            '                </div>' +
            '            </div><div class="user-action"></div></div>';

        var actHtml = '';//活动内容
        var actStatus = '';//活动状态


        if (listData.status == 1) {
            actStatus = '<p class="status status1">报名中</p>'
        } else if (listData.status == 2) {
            actStatus = '<p class="status status3">进行中</p>'
        } else if (listData.status == 3) {
            actStatus = '<p class="status status2">已结束</p>'
        } else {
            actStatus = '<p class="status status2">已取消</p>'
        }

        var icon_img = ''
        if(isDefine(listData.icons_path)){
            icon_img = listData.icons_path[0]
        }else {
            icon_img = listData.background_path;
        }
        var activity = {'activity_id': listData.id};
        actHtml = '<div class="flex-div" tapmode onclick=\'commonUrl("../activity/activity_index",' + jsonChange(activity) + ')\'>' +
            '                    <div class="act-img bg-cover" style="background-image: url(' + ajaxUrl + icon_img + ')"></div>' +
            '                    <div class="act-info">' +
            '                        <h6 class="single-ellipsis">' + listData.title + '</h6>' +
            '                        <div class="act-time">' +
            '                            <p class="time">' + listData.week + ' ' + listData.start_date + '</p>' + actStatus + '</div>' +
            '                        <div class="act-place">' +
            '                            <p class="place">' + listData.address + '</p>' +
            '                            <p class="num">' + listData.sum_number + '/' + listData.number + '</p>' +
            '                        </div>' +
            '                    </div>' +
            '                </div>';

        listHtml += '<li style="border-bottom: 1px #f0f0f0 solid;" class="list-li">' + userInfo + actHtml + hotHtml + '</li>';

        return listHtml;
    }

    function getDataType(item) {
        var result = '帖子';
        var url = '../circle/invite_detail';
        var urlParam = {'invitation_id': item.article_id};
        switch (item.type) {
            case 1:
                result = '新闻';
                url = '../index/news_detail';
                urlParam = {'news_id': item.article_id};
                break;
            case 2:
                result = '帖子';
                url = '../circle/invite_detail';
                urlParam = {'invitation_id': item.article_id};
                break;
            case 3:
                result = '活动';
                url = '../activity/activity_index';
                urlParam = {"activity_id": item.article_id};
                break;

        }
        return {
            text: result,
            url: url,
            urlParam: urlParam
        }
    }

</script>
